package com.ym.core.config;


import com.ym.medical.dao.SysRoleDataRuleDao;
import com.ym.medical.domain.param.SysRoleDataRuleQueryParam;
import com.ym.medical.domain.vo.SysRoleDataRuleListPcVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * spring启动以后操作
 *
 * @author: 李涛
 * @version: 2019年11月20日 22:13
 */
@Component
public class SpringRunAfterConfig implements ApplicationRunner {

	private static final Logger LOG = LoggerFactory.getLogger(SpringRunAfterConfig.class);

	@Autowired
	private SysRoleDataRuleDao sysRoleDataRuleDao;

	public static final List<SysRoleDataRuleListPcVO> sysRoleDataRules = new ArrayList<>();

	@Override
	public void run(ApplicationArguments args) throws Exception {
		//处理数据权限规则
		processSysRoleDataRules();


	}

	private void processSysRoleDataRules() {
		List<SysRoleDataRuleListPcVO> sysRoleDataRuleListPcVOS = sysRoleDataRuleDao.selectListPC(SysRoleDataRuleQueryParam.builder().build());
		sysRoleDataRules.addAll(sysRoleDataRuleListPcVOS);
	}


}
